<?php
/**
 * 执行提交主题相关操作
 * [ranknow bbs!] (C)2009-2015 ranknow.cn.
 *
 * @author liwei
 * @This is NOT a freeware, use is subject to license terms
 * @rcsfile $RCSfile: do_thread.php,v $
 * @revision $Revision: 0.1 $
 * @date $Date: 2009/12/30 09:40:17 $
 */
require_once '../../config.inc.php';
include BBS_MDL_PATH . 'mdl_post.php';
include BBS_MDL_PATH . 'mdl_thread.php';
$action = $_GET['action']?$_GET['action']:'';
$current_time = time();
dbConnect();
$ret = 'fail';
if ( $action == 'new_thread' && $_SESSION['bbs_user_id'] ) {
    $fid = $_POST['fid']?$_POST['fid']:0;
    $subject = $_POST['subject']?$_POST['subject']:'';
    $message = $_POST['message']?$_POST['message']:'';
    $is_draft = $_POST['is_draft']?$_POST['is_draft']:'';
    $data_thread = array( 'fid' => $fid, 'subject' => $subject, 'dateline' => $current_time, 'lastpost' => $current_time, 'is_draft' => $is_draft,'author'=>$_SESSION['bbs_username'],'authorid'=>$_SESSION['bbs_user_id'] );
    add_thread( $data_thread );
    $tid = mysql_insert_id();
    if($tid){
      $data_post = array( 'tid'=>$tid,'first'=>'1', 'fid'=>$fid,'subject'=>$subject,'dateline'=>$current_time,'message'=>$message,'author'=>$_SESSION['bbs_username'],'authorid'=>$_SESSION['bbs_user_id']);
      add_post( $data_post );
      $ret = $tid;
    }
    echo $ret;
}
dbDisconnect();
?>